<template>
  <div class="form-layout">
    <!--左侧导航-->
    <div class="nav-left">
      <customAnchor
        :itemList="[
          { name: 'box-base', title: '基础信息' },
          { name: 'box-more', title: '管理信息' },
        ]"
      />
    </div>

    <!--表单区域-->
    <div class="form-right" ref="formRight">
      <customForm :data="form" :rules="propRules" ref="editForm" :disabled="propReadonly">
        <template #content>
          <div id="box-base" class="box-title">基础信息</div>
          <customFormItem
            label="仓库名称"
            name="name"
            :parent="_self"
            :form="form"
          />
          <customFormItem
            label="仓库代码"
            name="code"
            :parent="_self"
            :form="form"
            help="不可重复"
          />
          <customFormItem label="请领仓库" name="applyWarehouseName" :parent="_self" :form="form"
                          :readonly="true"
                          :showSelectIcon="true"
                          @focus="utilSelect.warehouse(tableDrawerWarehouseConfirm)"
          />
          <customFormItem label="地址" name="address" :parent="_self" :form="form"
              :type="constCommon.formItemType.textarea.name"
              fullWidth
          />

          <div id="box-more" class="box-title">管理信息</div>
          <customFormItem label="中心仓库" name="flagCenter" :parent="_self" :form="form"
                          :type="constCommon.formItemType.switch.name"
                          help="中心仓库一般一个院区一个" :config="{flagValueBoolean: false}"
          />
          <customFormItem label="消毒供应室" name="flagDisinfection" :parent="_self" :form="form"
                          :type="constCommon.formItemType.switch.name"
                          help="消毒供应室一般一个院区一个" :config="{flagValueBoolean: false}"
          />

        </template>
      </customForm>
    </div>
  </div>
</template>

<script>
import customAnchor from '@/components/custom/form/customAnchor.vue'

export default {
  data() {
    return {
      form: {},
      viewData: {}
    }
  },
  methods: {
    // 仓库选择确认
    tableDrawerWarehouseConfirm(row) {
      this.$set(this.form, 'applyWarehouseId', row.id)
      this.$set(this.form, 'applyWarehouseName', row.name)
    }
  },
  created() {
    this.$emit('event-register', {
      validate: (callback) => {
        return this.$refs.editForm.validate(callback)
      },
      beforeSave: () => {
        this.$emit('data-callback', this.form)
        return true
      },
      afterMove: (formData, initData) => {
        this.form = global.utils.jsonClone(formData)
      },
      afterSave: () => {

      },
      beforeDelete: () => {
        return true
      },
      afterDelete: () => {
      },
      beforeFlow: (flowButtonKey) => {
        return true
      },
      afterFlow: (flowButtonKey) => {
      },
      beforeClose: () => {
        return true
      }
    })
  },
  props: {
    propParent: Object,
    propInitData: Object,
    propPrimaryKey: String,
    propDictionaries: Object,
    propCurrentRow: Object,
    propViewFormData: Object,
    propReadonly: Boolean,
    propStatus: String,
    propRules: Object
  },
  components: {customAnchor},
  computed: {}
}
</script>

<style lang="scss" scoped>
  .container {
    width: 100%;
    height: 100%;
  }
</style>
